package com.dhy.payutil.sample;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.dhy.payutil.PayCallback;
import com.dhy.payutil.PayStatus;
import com.dhy.payutil.alipay.AlipayHelper;
import com.dhy.payutil.wechat.WechatPayHelper;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
	}

	public void alipay(View view) {
		AlipayHelper alipayUtil = new AlipayHelper(this);
		alipayUtil.pay("测试的商品", "该测试商品的详细描述", 0.01f, "OutTradeNo", "notify_url", new PayCallback() {
			@Override
			public void callback(PayStatus result) {
				String msg = null;
				switch (result) {
					case ok:
						msg = "支付成功";
						break;
					case waiting:
						msg = "支付结果确认中";
						break;
					case failed:
						msg = "支付失败";
						break;
					case dataError:
						msg = "dataError";
						break;
				}
				Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();
			}
		});
	}

	public void showSign(View view) {
		WechatPayHelper.logAppSign(this, "WeChat");
	}

	public void wechatPay(View view) {
		// TODO: 2016/6/14
	}

	public void clickEvent1(View view) {
		Toast.makeText(this, "hello world", Toast.LENGTH_LONG).show();
	}
}
